
package com.insigma.business.qrcode.soldier.service.impl;



import com.insigma.business.qrcode.common.service.SequenceGenerator;
import com.insigma.business.qrcode.soldier.dao.CompanyDao;
import com.insigma.business.qrcode.soldier.dto.CompanyBSearcher;
import com.insigma.business.qrcode.soldier.entity.CompanyDO;
import com.insigma.business.qrcode.soldier.entity.CompanyPositNoFairIdDO;
import com.insigma.business.qrcode.soldier.entity.DataStatsCDO;
import com.insigma.business.qrcode.soldier.entity.KeyValueCDO;
import com.insigma.business.qrcode.soldier.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


@Service("companyService")
public class CompanyServiceImpl implements CompanyService {

    @Autowired(required = false)
    private CompanyDao companyDao;
    @Autowired(required = false)
    private SequenceGenerator sequenceGenerator;

    
    @Override
    public List<CompanyDO> search(final CompanyBSearcher companyBSearcher) {
        return companyDao.search(companyBSearcher);
    }

    @Override
    public List<CompanyPositNoFairIdDO> getCompanyPositNoFairId() {
        return companyDao.getCompanyPositNoFairId();
    }


    @Override
    public CompanyDO get(final String id) {
        return companyDao.get(id);
    }

    
    @Override
    public Integer insert(final CompanyDO companyDO) {
        companyDO.setId(sequenceGenerator.genKey("COMPANY_ID"));
        return companyDao.insert(companyDO);
    }

    
    @Override
    public Integer update(final CompanyDO companyDO) {
        return companyDao.update(companyDO);
    }

    
    @Override
    public Integer delete(final String id, final String modifierType, final String modifierId) {
        return companyDao.delete(id, modifierType, modifierId);
    }

    
    @Override
    public CompanyDO getByUserId(final String userId) {
        return companyDao.getByUserId(userId);
    }

    @Override
    public List<CompanyDO> searchByQualification(CompanyBSearcher companyBSearcher) {
        return companyDao.searchByQualification(companyBSearcher);
    }

    
    @Override
    public List<KeyValueCDO> listId2ValueByIdList(final List<String> idList) {
        return companyDao.listId2ValueByIdList(idList);
    }

    @Override
    public Integer count() {
        Integer integer = companyDao.count();
        if (integer == null) {
            return 0;
        }
        return integer;
    }

    @Override
    public List<DataStatsCDO> groupCompanyType() {
        return companyDao.groupCompanyType();
    }

    @Override
    public int countByBetweenTime(Date startTime, Date endTime) {
        Integer integer = companyDao.countByBetweenTime(startTime, endTime);
        if (integer == null) {
            return 0;
        }
        return integer;
    }

    @Override
    public CompanyDO getByCompanyName(String name) {
        return companyDao.getByCompanyName(name);
    }

}
